package com.mimc.controller.api;

import com.jfinal.aop.Aop;
import com.mimc.core.model.ImUser;
import com.mimc.core.service.ImUserService;
import com.mimc.framework.jwt.ApiTokenUtils;
import com.mimc.framework.utils.TranslateUtil;
import io.jboot.web.controller.JbootController;

public class BaseController extends JbootController {

    protected String translate(String key){
        return TranslateUtil.translate(key);
    }
    protected Long getUserId(){
        return ApiTokenUtils.getCurrentUserId();
    }
    protected String getSource(){
        return ApiTokenUtils.getSource();
    }
    //好友朋友版本+1
    protected Integer incUserFriendVersion(){
        ImUser user=ApiTokenUtils.getCurrentUser();
        Integer version=user.getFriendVersion()+1;
        user.setFriendVersion(version);
        ImUserService service= Aop.get(ImUserService.class);
        service.update(user);
        return version;
    }
}
